package com.liu.minio.controller;

import com.liu.minio.utils.MinioFileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author ch3nw3i@gitee
 */
@RestController
@RequestMapping("")
public class OssController {
    @Autowired
    MinioFileUtil minioFileUtil;



    @PostMapping("upload")
    public String upload(MultipartFile file) {
        try {
            //返回上传oss的url
            String url  = minioFileUtil.uploadFile(file);
            return url;
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("上传失败");
        }

    }

}
